package top.drose;


import java.util.Scanner;

//结构体实现双端链表
public class p4_2 {

    static class Node_Array {
        int id;
        int nextId;
        int priedId;

        Node_Array() {
            this.id = -1;
            this.nextId = -1;
            this.priedId = -1;
        }

    }


    public static void main(String[] args) {
        int n, m;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        Node_Array[] arr = new Node_Array[105];
        for (int i = 0; i <= n; i++) {
            arr[i] = new Node_Array();
        }
        for(int i=1;i<=n;i++){
            arr[i].id=i;
            arr[i].nextId=i+1;
            arr[i].priedId=i-1;
        }
        //开始数数
        //首位相连形成一个环
        arr[n].nextId=1;
        arr[1].priedId=n;
        int now=1;
        while((n--)>1){
            //数m-1下，让now变为m
            for(int i=1;i<m;i++){
                now=arr[now].nextId;
            }
            System.out.print(arr[now].id+" ");
            //然后断开
            int pre=arr[now].priedId;
            int next=arr[now].nextId;
            arr[pre].nextId=arr[now].nextId;
            arr[next].priedId=arr[now].priedId;
            now=next;//后移
        }
        System.out.print(arr[now].id+" ");

    }

}
